/**
 * Created by 小敏哥 on 2017/9/22.
 */
class CookiesOperation{
    //设置cookie
    setCookie(cname, cvalue, exdays) {
        var d = new Date();
        d.setTime(d.getTime() + (exdays*24*60*60*1000));
        var expires = "expires="+d.toUTCString();
        document.cookie = cname + "=" + cvalue + "; " + expires;
    }
//获取cookie
    getCookie(cname) {
        var ca = document.cookie.split(';');
        for (var i = 0; i < ca.length; i++) {
            var dic = ca[i].replace(/ /g, '').split('=');
            if (dic[0] == cname) {
                return dic[1];
            }
        }
        return "";
    }
//清除cookie
    clearCookie(name) {
        this.setCookie(name, "", -1);
    }
}

export default new CookiesOperation();